package com.cristina.attention.handler;

import com.cristina.attention.domain.MessageInfo;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * 处理 IM 渠道的 handler
 *
 * @author by superman
 */
public abstract class ImHandler {

    /**
     * 标识渠道的 code
     * 子类初始化的时候指定
     */
    protected Integer channelCode;

    @Resource
    private ImHandlerHolder imHandlerHolder;

    @PostConstruct
    private void init() {
        imHandlerHolder.putHandler(channelCode, this);
    }

    public void doHandler(MessageInfo messageInfo) {
        handler(messageInfo);
    }

    /**
     * 批处理 (针对 IM 业务)
     * @param taskInfo
     */
    public abstract void handler(MessageInfo taskInfo);
}
